<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ page import="org.jbpm.graph.def.*" %>
<%@ page import="org.jbpm.graph.exe.*" %>
<%@ page import="org.jbpm.db.*" %>
<%@ page import="org.jbpm.*" %>
<%@ page import="com.gzgi.workflow.jbpm.model.*" %>
<%@ page import="com.gzgi.workflow.jbpm.context.*" %>
<%@ page import="com.gzgi.workflow.jbpm.service.*" %>
<%@ page import="com.gzgi.workflow.jbpm.datafield.*" %>
<%@ page import="com.gzgi.workflow.jbpm.container.*" %>
<%@ page import="com.gzgi.framework.util.*" %>
<%@ page import="org.apache.commons.lang.*" %>
<%@ include file="/pages/system/checkAdmin.jsp"%>
<%
        RequestUtil.setRequestParameterToAttribute(request);
        Map params = new HashMap();
		String isAgree = request.getParameter("isAgree");
		String actorId = request.getParameter("actorId");
		String opinion = request.getParameter("opinion");
		String processInstanceId = request.getParameter("processInstanceId");
		 
		if(actorId == null){
			actorId = "admin";
		}
		if(isAgree == null){
			isAgree = "true";
		}
		 

		DataField datafield = new DataField();
		datafield.setName("isAgree");
        datafield.setValue(isAgree);

		DataField datafield4 = new DataField();
		datafield4.setName(request.getParameter("name"));
        datafield4.setValue(request.getParameter("value"));

		DataField datafield5 = new DataField();
		datafield5.setName(request.getParameter("rowId"));
        datafield5.setValue(request.getParameter("rowValue"));

        Collection datafields = new ArrayList();
        datafields.add(datafield);
		datafields.add(datafield4);
		datafields.add(datafield5);

		try {
			if(processInstanceId != null && processInstanceId.length()>0){
				ProcessContext ctx = new ProcessContext();
				ctx.setActorId(actorId);
				ctx.setOpinion(opinion);
				ctx.setContextMap(params);
				ctx.setDataFields(datafields);
                ctx.setProcessInstanceId(processInstanceId);
                boolean isOK = ProcessContainer.getContainer().completeTask(ctx);
				out.println("isOK="+isOK);
			}
		}catch (Exception ex) {
			ex.printStackTrace();
			throw new RuntimeException(ex);
		}
%>

<script language="JavaScript">
    function submitForm(isAgree){
        document.getElementById("isAgree").value=isAgree;
		document.iForm.bt01.disabled=true;
		document.iForm.bt02.disabled=true;
        document.iForm.submit();
     }
</script>
<center>
<form name="iForm" method="post" action="task_finish.jsp">
  <table align="center" class="table-border" cellspacing="1" cellpadding="4" width="90%" nowrap>
    <tr class="table-bar" align="middle" nowrap>
	<td align="center"  nowrap> 
    <input type="hidden" id="isAgree" name="isAgree" value=""><br>
	process actorId 
	</td>
	<td align="left"  nowrap> 
	<input type="text" name="actorId" value="" size="50">
	</td>
	</tr>
    <tr class="table-bar" align="middle" nowrap>
	<td align="center"  nowrap> processInstanceId 
    </td>
	<td align="left"  nowrap> 
	<input type="text" name="processInstanceId" value="" size="50">
	</td>
	<tr class="table-bar" align="middle" nowrap>
	<td align="center"  nowrap> 
	name:</td>
	<td align="left"  nowrap> 
	<input type="text" name="name" value="" size="50">
	</td>
	</tr>
	<tr class="table-bar" align="middle" nowrap>
	<td align="center"  nowrap> 
	value:
	</td>
	<td align="left"  nowrap> 
	<input type="text" name="value" value="" size="50">
	</td>
	</tr>
	<tr class="table-bar" align="middle" nowrap>
	<td align="center"  nowrap> 
	row Id:</td>
	<td align="left"  nowrap> 
	<input type="text" name="rowId" value="" size="50">
	</td>
	</tr>
	<tr class="table-bar" align="middle" nowrap>
	<td align="center"  nowrap> 
	row value:</td>
	<td align="left"  nowrap> 
	<input type="text" name="rowValue" value="" size="50">
	</td>
	</tr>
    <tr class="table-bar" align="middle" nowrap>
	<td align="center"  nowrap> 
	opinion:</td>
	<td align="left"  nowrap> 
	 <textarea name="opinion" rows="5" cols="40"></textarea>
	</td>
	</tr>
	<tr class="table-bar" align="middle" nowrap>
	<td align="center" colspan="4"  nowrap> 
	<input type="button" name="bt01" value="通过" onclick="submitForm('true');">
	<input type="button" name="bt02" value="不通过" onclick="submitForm('false');">
	</td>
	</tr>
  </table>
</form>
</center>
